package com.etheart.framework.web.util;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

import org.apache.commons.lang.StringUtils;

public class URLUtils {
	
	public static String urlDecode(String s) {
        if (StringUtils.isBlank(s))
            return s;
        try {
            s = URLDecoder.decode(s, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return s;
    }
	
	public static String urlEncode(String s) {
        if (StringUtils.isBlank(s))
            return s;
        try {
            s =URLEncoder.encode( URLEncoder.encode(s, "UTF-8"),"UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return s;
    }
}
